package com.example.play.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.annotation.Order;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;


/**
 * @author wsl
 * @version 1.0
 * @date 2020/4/14
 * @description 这是 swagger文档配置
 */

@Configuration
@EnableKnife4j
@Import(BeanValidatorPluginsConfiguration.class)
public class SwaggerConfiguration {
    @Bean(value = "fileApi")
    @Order(value = 1)
    public Docket groupRestApi() {
        return new Docket (DocumentationType.SWAGGER_2)
                .apiInfo (groupApiInfo ())
                .select ()
                .apis (RequestHandlerSelectors.basePackage ("com.bsgd.file.controller"))
                .paths (PathSelectors.any ())

                .build ();
    }

    private ApiInfo groupApiInfo() {
        return new ApiInfoBuilder ()
                .title ("这是文件上传的接口文档")
                .description ("<div style='font-size:14px;color:red;'>swagger-bootstrap-ui-demo RESTful APIs</div>")
                .termsOfServiceUrl ("http://www.botovision.com/")
                .contact ("wushenglu@botovision.com")
                .version ("1.0")
                .build ();
    }

}
